package yz.mr.FiltrationText2;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 *  * Mapper阶段：
 *  *      ①读取数据并且进行切分，读出数据信息
 *  *      ②对班级信息做为key，将其他的信息作为value
 */
public class FiltrationText2Mapper extends Mapper<LongWritable, Text, Text,Text> {
    /**
     * @param key  班级作为Key
     * @param value 其他信息
     * @param context
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        //1500100001	施笑槐,22,女,文科六班,406 获取一行数据
        String Line = value.toString();
        String[] OtherInfo = Line.split(",");
        String clazz = OtherInfo[3];
        context.write(new Text(clazz),value);
    }
}
